using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ShivamEMR.Model.Domain.PatientDomain;
using ShivamEMR.Model.DataInterfaces.PatientDataInterf;
using ShivamEMR.Model;
//using ShivamEMR.Web.Areas.Patient.Models;

namespace ShivamEMR.Web.Areas.Patient.Controllers
{   
    public class AdmissionTypeController : Controller
    {
		private readonly IAdmissionTypeRepository admissiontypeRepository;

		// If you are using Dependency Injection, you can delete the following constructor
        public AdmissionTypeController() 
        {
            admissiontypeRepository = Registry.RepositoryFactory.GetAdmissionTypeRepository();
        }

        public AdmissionTypeController(IAdmissionTypeRepository admissiontypeRepository)
        {
			this.admissiontypeRepository = admissiontypeRepository;
        }

        //
        // GET: /AdmissionType/

        public ViewResult Index()
        {
           // return View(admissiontypeRepository.AllIncluding(admissiontype => admissiontype.Admissions));
            return View(admissiontypeRepository.All);
        }

        //
        // GET: /AdmissionType/Details/5

        public ViewResult Details(int id)
        {
            return View(admissiontypeRepository.Find(id));
        }

        //
        // GET: /AdmissionType/Create

        public ActionResult Create()
        {
            return View();
        } 

        //
        // POST: /AdmissionType/Create

        [HttpPost]
        public ActionResult Create(AdmissionType admissiontype)
        {
            if (ModelState.IsValid) {
                admissiontypeRepository.InsertOrUpdate(admissiontype);
                admissiontypeRepository.Save();
                return RedirectToAction("Index");
            } else {
				return View();
			}
        }
        
        //
        // GET: /AdmissionType/Edit/5
 
        public ActionResult Edit(int id)
        {
             return View(admissiontypeRepository.Find(id));
        }

        //
        // POST: /AdmissionType/Edit/5

        [HttpPost]
        public ActionResult Edit(AdmissionType admissiontype)
        {
            if (ModelState.IsValid) {
                admissiontypeRepository.InsertOrUpdate(admissiontype);
                admissiontypeRepository.Save();
                return RedirectToAction("Index");
            } else {
				return View();
			}
        }

        //
        // GET: /AdmissionType/Delete/5
 
        public ActionResult Delete(int id)
        {
            return View(admissiontypeRepository.Find(id));
        }

        //
        // POST: /AdmissionType/Delete/5

        [HttpPost, ActionName("Delete")]
        public ActionResult DeleteConfirmed(int id)
        {
            var atype = admissiontypeRepository.Find(id);
            admissiontypeRepository.Delete(atype);
            admissiontypeRepository.Save();

            return RedirectToAction("Index");
        }
    }
}

